<?php
/*
 * 生成违章查询json
 * @author     Mark <zhaody901@126.com>
 * @copyright  Copyright (c) 2013 lemon team
 * @version    $Id: ab8e261615505428fa4264fc1115db935c4273ba $
 * @time       14-2-7 上午10:09
 */
include '../../common.inc.php';
$area = $db->getAll("select areaname as n,areaid as id from xd_area where parentid=0");
foreach($area as $k=>$v){
	$num = str_pad($v['id']+15,8,0,STR_PAD_RIGHT);
	$str[$num] = $v;
}
foreach($str as $k=>$v){
	$shis = '';
	$shi = $db->getAll("select a.areaname as n ,a.url as id,a.areaid from xd_area_chaxun as a ,xd_area as b  where b.parentid=".$v['id']." and a.areaid = b.areaid and a.url!=''" );
	if(empty($shi)){$shi = $db->getAll("select areaname as n,url as id,areaid from xd_area_chaxun where areaid = ".$v['id']." and url!=''");}
	foreach($shi as $d=>$c){
		$num = str_pad(($k/1000000).($d+15),8,0,STR_PAD_RIGHT);
		$shis[$num] = $c;
	}
	$str[$k]['c'] = $shis;
	$str[$k]['l'] = count($shis);
}
echo json_encode($str);
